16. functions
你好。
Hello.
在本教程中,我们将使用函数,并学习如何创建函数?
In this tutorial, we will work with the functions and we will learn how can we create a function?
我们如何在我的项目中使用这个功能?
How can we use this function into my project?
首先,函数和功能块有什么区别?
Firstly, what is the difference between function and function block?
功能块之间的主要区别需要命名。
The main difference between the function blocks needs a name.
每个功能块都需要一个名称,但函数不需要名称。
Each function block needs a name, but the functions doesn't need a name.
好的。
OK.
进入左侧,你会看到一个功能区、区块和功能区。
Into the left side, you will see a function, block and function area.
右键单击并添加新数据,我将选择现在的函数和该函数的名称。
Right click and add the new data, and I will select now function and the name of this function.
就说计算器吧。
Let's say calculator.
或者我们将如何计算一件事和编程语言可以稍后我和格雷厄姆会说。
Or how we will calculate one thing and programming language can be later that Graham and I will say it.
好的。
Yes, OK.
而这里的标签名称我们可以说我们可以输入。
And the label name here we can say we can input.
我们可以定义或创建变量输入和输出。
We can define or create and variable input and output.
首先我们来说说输入。
Firstly, let's say input.
这将是我的输入,这将是浮动数据,好吗?
And this is going to be my input and this is going to be floating data, OK?
这取决于您的项目,这将是我的变量输入。
It is up to your project and this will be my variable input.
让我们说一下输出。
And let's say output.
这将是浮动数据,让我们从这里设置它。
And this is going to be floating data and let's set it from here.
单精度然后可变输出,仅此而已。
Single precision and then variable output, that's all.
这是我在函数中为函数定义标签的方法。
This is my how we can define a label for my function in my function.
我该怎么办?
What will I do?
我会说LDA是一千。
I will say LDA is a thousand.
这是我平时经常联系的。
This is my normally always on contact.
我通常打开联系。
I normally open contact.
我们会怎样做?
What will we do?
到时候我们再做一件事。
We will do one more thing then.
例如,我的输入乘以。
And my input multiply by, for example.
三点十五分。
Three point fifteen.
它将被写入输出。
And it's going to be written into output.
好的?
OK?
然后就可以了。
And then this is OK.
这是第一件事,也是节目好友区。
This is the first thing and the program buddy area.
我们只需点击这里,我们就可以通过拖放的方法,我们可以把它放到这里。
We can just click to here and we can with the drag and drop method, we can put it to here.
就这个吧,好吗?
Just this one, OK?
但这不是正确的模式。
But this is not in the right mode.
好的,让我们现在开始,我们可以将这个计算器放在这里并启用它。
OK, let's go to right now and this calculator we can put it to here and this enable it.
我会把它放在这里。
And I will put it to here.
以及说谎。
And for lying.
好的,棒极了。
OK, very good.
而这个输入我们可以从这里选择,比如我们选择这16个,可以吗?
And this input we can select from here, for example, let's select these 16, OK?
产量将恢复到 20。
And the output is going to be returning to the 20.
没关系。
That's OK.
而且不需要在这里输入名称。
And there's no need a put here a name.
再说一次,我可以把我的计算器放在这里。
And again, I can put my calculator to here this right here.
14 就是这样,输出将是 22。
The 14 like that and output is going to be 22.
而这则不同。
And this is different.
这是不同的功能。
This is different function.
这个功能是相同的,但是我们可以与另一个工作一起使用这个相同的功能以及四个和其他进程。
This function are same, but we can use with another work this same function with and four and other processes.
好的。
OK.
而启用则不然。
And enable is less so.
将其复制并写到此处并以水平线列出。
Copy it and write it to here and list it for horizontal line.
我现在就转换我的项目,就可以了。
And I will convert my project now, and it's OK.
现在已经转换完毕,一切正常。
And it is converted now and everything's OK.
我现在将启动我的模拟器。
And I will start my simulator now.
是的,你知道,骑行结束后,你会立即看到结果,因为为什么从这里来的很远。
It's right, you know, and riding is finished, then you will see the results immediately because of why the far comes from here.
16倍除以2.5又是4。
The 16 time divided by 2.5 and four.
这是输入如下。
And this is the input as follows.
结果是十二点六百。
And the result is twelve point six hundred.
好的,我们来计算 4.00 乘以三点十五分。
OK, let's calculate 4.00 to multiply by three point fifteen.
结果是正确的。
And the result is correct.
在这里,四点八百乘以三点十五分。
And here, four point eight hundred multiply by three point fifteen.
结果是正确的。
And the result is correct.
好的。
OK.
这就是我们如何使用该函数,该函数不需要名称,并且该函数可以在您的项目中大量使用。
This is how we can work with the function with the function does not require a name, and this function can be used a lot of time into your project.
这就是我们如何写入函数,好吗?
And this is how we can write into the function, OK?
我们可以编写很多项目调用到这里,并且我们可以很容易地在主程序中使用它。
We can write a lot of project called to here, and we can use it easily into main program.
这对于本教程来说真的非常非常重要。
This is really, really, really important for this tutorial.
我到这里就结束了。
I'm finished here.
下一个教程见?
See you in your next tutorial?